using System;
using System.Collections.Generic;

namespace SY.WebSite.Entity
{
	/// <summary>
	///	
	/// </summary>
	[Serializable]
	public class IntegrationTransaction : IEntity
	{
		public const string RESERVE_CONST = "IntegrationTransaction";
			
		#region Private Members
		private int _id; 
		private int _fromUserId; 
		private string _fromUserName; 
		private int _toUserId; 
		private string _toUserName; 
		private int _type; 
		private int _targetId; 
		private int _amount; 
		private string _comment; 
		private DateTime _dateTime; 		
		[NonSerialized]
        private string _reserve;
		#endregion
		
		#region Default ( Empty ) Class Constuctor
		/// <summary>
		/// default constructor
		/// </summary>
		public IntegrationTransaction()
		{
			_id = 0; 
			_fromUserId = 0; 
			_fromUserName = null; 
			_toUserId = 0; 
			_toUserName = null; 
			_type = 0; 
			_targetId = 0; 
			_amount = 0; 
			_comment = null; 
			_dateTime = new DateTime(); 
		}
		#endregion // End of Default ( Empty ) Class Constuctor
		
		public Dictionary<string, object> ToDictionary()
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
		
			dictionary.Add("Id",_id);
			dictionary.Add("FromUserId",_fromUserId);
			dictionary.Add("FromUserName",_fromUserName);
			dictionary.Add("ToUserId",_toUserId);
			dictionary.Add("ToUserName",_toUserName);
			dictionary.Add("Type",_type);
			dictionary.Add("TargetId",_targetId);
			dictionary.Add("Amount",_amount);
			dictionary.Add("Comment",_comment);
			dictionary.Add("DateTime",_dateTime);
			
			dictionary.Add("Reserve",Reserve);//特殊
			return dictionary;
		}
		
		#region Public Properties
		/// <summary>
		/// 
		/// </summary>		
		public int Id
		{
			get { return _id; }
			set { _id = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int FromUserId
		{
			get { return _fromUserId; }
			set { _fromUserId = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string FromUserName
		{
			get { return _fromUserName; }
			set	
			{
				if( value!= null && value.Length > 16)
					throw new ArgumentOutOfRangeException(@"Invalid value for FromUserName", value, value);
				
				_fromUserName = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int ToUserId
		{
			get { return _toUserId; }
			set { _toUserId = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string ToUserName
		{
			get { return _toUserName; }
			set	
			{
				if( value!= null && value.Length > 16)
					throw new ArgumentOutOfRangeException(@"Invalid value for ToUserName", value, value);
				
				_toUserName = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int Type
		{
			get { return _type; }
			set { _type = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int TargetId
		{
			get { return _targetId; }
			set { _targetId = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int Amount
		{
			get { return _amount; }
			set { _amount = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string Comment
		{
			get { return _comment; }
			set	
			{
				if( value!= null && value.Length > 500)
					throw new ArgumentOutOfRangeException(@"Invalid value for Comment", value, value);
				
				_comment = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public DateTime DateTime
		{
			get { return _dateTime; }
			set { _dateTime = value; }
		}
			
		/// <summary>
        /// 保留属性
        /// </summary>
        public string Reserve
        {
            get 
            {
                if (string.IsNullOrEmpty(_reserve))
                    return RESERVE_CONST  ;

                return _reserve; 
            }
            set { _reserve = value; }
        }
		#endregion 
	}
}
